package com.mine.vioceplaylib.utils;

import android.app.Application;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Tools {

    public static Application getApplication() {
        Application application = null;

        try {
            Class<?> aClass = Class.forName("android.app.ActivityThread");
            Method currentApplication = aClass.getMethod("currentApplication");
            currentApplication.setAccessible(true);
            application = (Application) currentApplication.invoke(null);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return application;
    }
}
